<?php

use yii\helpers\Html;
//use yii\grid\GridView;
use kartik\grid\GridView;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\SendMsgSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '消息推送记录';
$this->params['breadcrumbs'][] = ['label' => '客户管理', 'url' => ['/customer/index']];
$this->params['breadcrumbs'][] = $this->title;
$js = <<<JS
$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
JS;
$this->registerJs($js);
?>
<div class="send-msg-index">

    <?php Pjax::begin(); ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
//            'id',
            [
                'attribute' => 'mobile',
                'value' => function ($model) {
                    return $model->customer->company . "\n" . $model->contact->contact . "\n" . $model->contact->post . "\n" . $model->mobile;
                }
            ],

//            'title',
            [
                'attribute' => 'content',
                'format' => 'raw',
                'value' => function ($model) {
                    return "<span title='" . $model->content . "' data-toggle='tooltip' data-placement='top'>" . mb_strcut($model->content, 0, 30) . "</span>";
                }
            ],
//            'type',
            'created_at',
            [
                'attribute' => 'user_id',
                'value' => function ($model) {
                    return $model->sender->realname;
                },

            ],
            [
                'attribute' => 'status',
                'class' => 'kartik\grid\BooleanColumn',
                'trueLabel' => '成功',
                'falseLabel' => '失败'
            ],
            'result:ntext',

//            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
    <?php Pjax::end(); ?>
</div>
